package com.cn.webspider;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Test {
    @org.junit.Test
    public void te1() {
        URLConnection urlConnection = null;
        try {
//            Pattern p = new Pattern("");
            URL url = new URL("http://www.baidu.com");
            urlConnection = url.openConnection();
            System.out.println(urlConnection.getContent());
            InputStream inputStream = urlConnection.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            String s = null;
            while ((s = bufferedReader.readLine()) != null) {
                System.out.println(s.toString());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
